<template>
  <div class="countdownPopo">
    <div class="bg" />
    <div class="box">
      <div class="title">提示</div>
      <p class="mess">{{ msg }}</p>
      <div class="butonBox">
        <el-button type="primary" @click="commitBtn">确定（ {{ num }} ）</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['countNum', 'jumpUrl', 'msg'],
  data() {
    return {
      timer: null,
      num: null
    }
  },
  created() {
    this.pourTimeFun(this.countNum)
  },
  methods: {
    // 倒计时
    pourTimeFun(countNum) {
      this.num = countNum
      this.timer = setInterval(() => {
        this.num--
        if (this.num == 0) {
          clearInterval(this.timer)
          this.jumpUrlFun()
        }
      }, 1000)
    },
    // 确定
    commitBtn() {
      clearInterval(this.timer)
      this.jumpUrlFun()
    },
    // 跳转路径
    jumpUrlFun() {
      this.$router.push({
        name: this.jumpUrl
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.countdownPopo {
	.bg {
		width: 100%;
		height: 100%;
		background-color: #000000;
		opacity: 0.5;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 100;
	}
	.box {
		width: 420px;
		padding-bottom: 10px;
		background-color: white;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		border-radius: 4px;
		border: 1px solid #e6ebf5;
		font-size: 18px;
		text-align: center;
		position: fixed;
		top: 50%;
		left: 50%;
		margin-left: -150px;
		margin-top: -100px;
		z-index: 101;
		.title {
			padding: 15px;
			padding-bottom: 10px;
		}
		.mess {
			padding-left: 36px;
			padding-right: 12px;
		}
		.butonBox {
			margin-top: 30px;
			width: 100%;
			display: flex;
			justify-content: space-around;
		}
	}
}
</style>
